<div class="x-list-title">
<table width="100%" border="0" height="100%">
	<tr>
		<td align="left">
			<h2>Lịch cơ quan tuần</h2>
		</td>
		<td align="right">	
			<div class="x-list-options">	
				<a href="#Calendar/Index/Add" class="x-button">Lịch cá nhân mới</a>
				<a href="#Calendar/Company/Add" class="x-button">Lịch cơ quan mới</a>
			</div>
		</td>
	</tr>
</table>	
</div>
<div class="calendar-bar-container">
	<div class="calendar-bar">
		<?php $time = $this->get('time');?>
		<?php $pre_date  = date('\y\e\a\r=Y&\w\e\e\k=W',strtotime("-1 week",$time));?>
		<?php $next_date = date('\y\e\a\r=Y&\w\e\e\k=W',strtotime("+1 week",$time));?>
		<div class="calendar-ctr">
		<a href="#Calendar/Company/Week?<?php _e($pre_date);?><?php if( isset($_GET['department_id'] )) _e('&department_id='.get('department_id')) ?>" class="pre-calendar"></a>
		<a href="#Calendar/Company/Week?<?php _e($next_date);?><?php if( isset($_GET['department_id'] )) _e('&department_id='.get('department_id')) ?>" class="next-calendar"></a></div>
		  Tuần <?php _e(date("W",$time))?> tháng <?php _e(date("m",$time))?> năm <?php _e(date("Y",$time))?>
		<?php include '_Options.phtml';?>
	</div>
</div>
<table width="100%" class="x-list" cellpadding="0" cellspacing="0">
<tr>
	<th width="100">Thời gian</th>
	<th>Nội dung</th>
	<th width="100">Phòng ban</th>
	<th width="100">Chuẩn bị</th>
	<th width="150">Tham gia</th>
	<th width="100">Địa điểm</th>
	<th width="100">Chủ trì</th>
</tr>
<?php foreach( $this->get('days') as $time => $posts ):?>
<?php 
	$html="";
	$rowspan=0;
	
	foreach( $posts as $a ){
		$atime = date('H:i',strtotime($a['time_start']))." &#187; ".date('H:i',strtotime($a['time_end']));
		$tooltip ="<div class='x-toolbox'>
			<div class='event-quick-box'>
			<div style='border-bottom:1px solid #ddd;padding:0px 0px 5px 0px'>
			<big><b>{$a['title']}</b></big><br/>
			<i>$atime</i><br/>
			</div><div style='padding:5px 0px'>
			".short_title(strip_tags($a['content']),300)."
			</div></div>
		</div>";
		
		if( $rowspan  == 0 ){
			$html .="<td><div class='calendar-post'>
					<a class='x-tooltip' href='#Calendar/Company/View?ID={$a['ID']}'>&#187; ".short_title($a['title'],30)."	$tooltip</a> ( $atime )
				</div></td>
				<td align='center'><a href='#Calendar/Company/Week?department_id={$a['department_id']}'>{$a['department_title']}</a></td>
				<td>{$a['tools']}</td>
				<td>{$a['guests']}</td>
				<td align='center'>{$a['place']}</td>
				<td align='center'>{$a['chairman']}</td>
			</tr>";			
			$rowspan++;
		}else{
			$html .="<tr>
				<td><div class='calendar-post'>
					<a class='x-tooltip' href='#Calendar/Company/View?ID={$a['ID']}'>&#187; {$a['title']}	$tooltip</a> ( $atime )
				</div></td>
				<td align='center'><a href='#Calendar/Company/Week?department_id={$a['department_id']}'>{$a['department_title']}</a></td>
				<td>{$a['tools']}</td>
				<td>{$a['guests']}</td>
				<td align='center'>{$a['place']}</td>
				<td align='center'>{$a['chairman']}</td>					
			</tr>";			
			$rowspan++;			
		}
	}	

	if( $rowspan  == 0 ){
		$html .="<td></td><td></td><td></td><td></td><td></td><td></td></tr>";		
	}	
?>	
<tr>
<?php $is_current = date('d/m/Y',$time) == date('d/m/Y') ? ' week-current':''?>
<td class="calendar-week-day<?php _e($is_current)?>"<?php _e($rowspan > 1 ? " rowspan='$rowspan'":'');?>>
	<a href="#Calendar?date=<?php _e(date("Y-m-d",$time))?>"><?php _e(vn_day($time));?><br/>
	<small><?php _e(date("d-m",$time))?></small></a>
</td>
<?php _e( $html );?>
<?php endforeach;?>
</table>
